﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using ETA.IRepository;
using ETA.Repositories;
using ETA.Entity;
using Ninject;
using ETA.Common;
namespace ETA.UnitTest
{
    [TestFixture]
    public class RolerTest
    {

        private static IKernel kernel = new StandardKernel(new NinjectModuleBuild());

        [Test]
        public void GetAllRolerTest()
        {
            IRolerRepository r = kernel.Get<IRolerRepository>();
            var list = r.GetAllList();
        }

        [Test]
        public void GetAllUserTest()
        {
            IUserRepository r = new UserRepository();
            var list = r.GetAllList();
        }

        [Test]
        public void AddUserTest()
        {
            IRolerRepository r0 = new RolerRepository();
            IUserRepository r = new UserRepository(); //  RolerId=""
            var user = new User();
            user.UserId = Guid.NewGuid().ToString();
            user.UserName = "Tommy";
            var roler = r0.Get("b635731b-d6a4-4d23-8f45-1dd8134a7356");
            user.AddRoler(roler);
            var res = r.Insert(user);
            var t = r.Get(user.UserId);
            Assert.IsNotNull(r.Get(user.UserId));
        }

        [Test]
        public void FeatureBannerTest()
        {
            IFeatureBannerRepository r = new FeatureBannerRepository();
            var list = r.GetAllList();
            Assert.AreEqual(list.Count, 3);
        }
        //6c850ada-8088-4276-9d66-15b24fcf38aa

        [Test]
        public void UpdateUserTest()
        {
            IUserRepository r = new UserRepository();
            var list = r.GetAllList(d => d.UserId == "6c850ada-8088-4276-9d66-15b24fcf38aa");
            if (list.Any())
            {
                var t = list.FirstOrDefault();
                t.UserName = "孙龙飞";
                r.Update(t);
            }
        }

        [Test]
        public void DeleteUserTest()
        {
            IUserRepository r = new UserRepository();
            r.LogincDelete("8853e932-7efb-4f5e-9db9-b5be9b8176a7");
        }

        [Test]
        public void LogTest()
        {
            Logger.Log.Info("测试日志");
        }

    }
}
